<%@ page import="com.kgc.service.NewsService" %>
<%@ page import="com.kgc.service.impl.NewsServiceImpl" %>
<%@ page import="com.kgc.entity.News" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    /*String path = request.getContextPath();
    String basePath = request.getServerName() + ":" + request.getServerPort() + path + "/";
    String baseUrlPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    pageContext.setAttribute("baseUrlPath", baseUrlPath);*/

    //获取请求时传来的新闻编号
    //request.getParameter("id");
    //获取NewsServiceImpl的对象
    NewsService newsService=new NewsServiceImpl();
    News news = newsService.queryNewsById(Integer.parseInt(request.getParameter("id")));
    //把news对象存到page作用域里.键值对。news---news
    pageContext.setAttribute("news", news);
%>
<html>
<head>
    <title>新闻详情页</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/css/common.css">
    <style>
        .picPathImg{
            display: block;
            margin: 10px auto;
            width: 200px;
        }
    </style>
</head>
<body>
<div class="main-content-right">
    <div class="main-text-box">
        <div class="main-text-box-tbg">
            <div class="main-text-box-bbg">
                <div class="article-box">
                    <!--新闻的标题-->
                    <h1>${news.title}</h1>
                    <div class="source-bar">发布者：${news.author}
                       <%-- <%=news.getAuthor()%>--%>
                        分类：新闻信息
                        更新时间：<%--<%=news.getCreateDate()%>--%>
                        ${news.createDate}
                    </div>
                    <div class="article-content">
                        <span class="article-summary">
                            <b>摘要：${news.summary}
                                <%--<%=news.getSummary()%>--%>
                            </b></span>
                        <%
                            if(news.getPicPath()==null || news.getPicPath().equals("")){
                         %>
                        新闻图片：暂无
                        <%
                            }else{
                         %>
                        <img class="picPathImg"  alt="图片找不到" src="<%=request.getContextPath() %>/static/upload/${news.picPath}"/>

                        <%
                            }
                        %>
                        <br/>
                      <%-- <%=news.getContent()%>--%>
                        ${news.content}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
